package isjinhao.jlox.lexical;

import lombok.Getter;

/**
 * @Author ISJINHAO
 * @Date 2021/2/20 17:03
 */
@Getter
public class Token {
    private final TokenType type;
    private final String lexeme;
    private final Object literal;
    private final int line;

    public Token(TokenType type, String lexeme, Object literal, int line) {
        this.type = type;
        this.lexeme = lexeme;
        this.literal = literal;
        this.line = line;
    }

    public Token(TokenType type) {
        this.type = type;
        this.lexeme = null;
        this.literal = null;
        this.line = -1;
    }

    @Override
    public String toString() {
        return type + " " + lexeme + " " + literal;
    }
}